// components/authorization/index.js
Component({
  data: {
    isLogin: false
  },
  lifetimes: {
    attached() {
      const isLogin = !!getApp().token
      this.setData({ isLogin })
      if (!isLogin) {
        // 读取当前历史栈
        const pageStack = getCurrentPages()
        // console.log(pageStack);
        // 取出当前页面路径，登录成功能跳转到该页面
        const currentPage = pageStack[pageStack.length - 1]
        const redirectURL = currentPage.route

        wx.redirectTo({
          url: '/pages/login/index?redirectURL=' + redirectURL,
        })
      }
    }
  }
})
